package com.caigou.desensitization.autoConfig;

import com.caigou.desensitization.plugin.DesensitizationInterceptor;
import com.caigou.desensitization.strategy.DesensitizationClearAspect;
import com.caigou.desensitization.strategy.SensitiveContext;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
public class DesensitizationAutoConfiguration {
	@PostConstruct
	public void start() {
		System.out.println("已开启字段脱敏功能！");
	}

	@Bean
	@ConditionalOnMissingBean
	public DesensitizationInterceptor desensitizationInterceptor() {
		return new DesensitizationInterceptor();
	}

	@Bean
	@ConditionalOnMissingBean
	public SensitiveContext sensitiveContext() {
		return new SensitiveContext();
	}

	@Bean
	@ConditionalOnMissingBean
	public DesensitizationClearAspect desensitizationClearAspect() {
		return new DesensitizationClearAspect();
	}

	@Bean
	@ConditionalOnMissingBean
	public DesensitizationProperties desensitizationProperties() {
		return new DesensitizationProperties();
	}
}
